#ifndef _TABLEFLIPPER_H_
#define _TABLEFLIPPER_H_	

#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define WINDOWS

#define iss(i)          ((i) == '\t' || (i) == ' ')
#define isn(i)          (i) == '\n'
#define isu(i)          isn(i) && iss(i)
#define display(arg)    cdisplay((arg) -> column, (arg) -> row, stdout, (arg))
#define RAND(A,B)       rand() % ((B) - (A) + 1) + (A)

typedef struct stu_obj{
    char*	name;
	int		rank;
} stu_t;

typedef struct class_obj{
	stu_t**	matrix;
	int 	column;
	int 	row;
} cpny_t;

typedef struct pos_obj{
	int x;
	int y;
} pos_t;

typedef enum direction_enum{Left, Right, Up, Down} dire;

cpny_t*  cinit        (char* filename);
char*    cinput       (char* filename);
void     det          (char* data, cpny_t* cpny);
void     clean        (char* data);
void     cdisplay     (int column, int row, FILE* fp, cpny_t* cpny);
stu_t**  alloc2DArray (int column, int row);
void	 cdealloc	  (cpny_t* cpny);

void	 cshl		  (cpny_t* cpny);
void	 cshr		  (cpny_t* cpny);
void	 cshu		  (cpny_t* cpny);
void	 cshd		  (cpny_t* cpny);

void     crnd         (cpny_t* cpny);
void 	 revertX   	  (cpny_t* cpny);
void 	 revertY	  (cpny_t* cpny);

void 	 cswap		  (cpny_t* cpny, pos_t first, pos_t second);

#endif